﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var sq = new Square(12);
            
            Console.WriteLine($"Area of the square = {sq.GetArea()}");
            Console.WriteLine($"Size of the square = {sq.GetSize()}");

            Console.ReadKey();
        }
    }

    class BaseShap
    {
        public virtual int GetSize()
        {
            return 0;
        }
    }

    abstract class Shape:BaseShap
    {
        public abstract int GetArea();

        // 可以覆盖掉父类的方法
        public override int GetSize()
        {
            return 1;
        }
    }

    class Square : Shape
    {
        private int _side;

        public Square(int n) => _side = n;

        public override int GetArea() => _side * _side;

        public override int GetSize()
        {
            Console.WriteLine($"Size of the square = {base.GetSize()}"); // 这个地方调用 Shape 类的方法
            return 2;
        }
    }
}
